let idGlobal = 1000;

export function createIdAndKey(item) {
  // console.log('item', item)
  const config = item.__config__;
  config.formId = ++idGlobal;
  config.renderKey = `${config.formId}${+new Date()}`; // 改变renderKey后可以实现强制更新组件
  if (config.layout === "colFormItem") {
    item.__vModel__ = `field${idGlobal}`;
  } else if (config.layout === "rowFormItem") {
    config.componentName = `row${idGlobal}`;
    !Array.isArray(config.children) && (config.children = []);
    delete config.label; // rowFormItem无需配置label属性
  }
  if (Array.isArray(config.children)) {
    config.children = config.children.map((childItem) =>
      createIdAndKey(childItem)
    );
  }
  return item;
}
